<template>
    <div id="dialog-container">
        <el-dialog v-dialogDrag 
            title="选择用户" append-to-body
            :visible.sync="dialogVisible" @close="$emit('update:show', false)" :before-close="handleClose" :show="show"
            :close-on-click-modal="false" width="700px">
            <el-row class="searchBox">
                <el-form :inline="true" size="small" label-width="70px">
                    <el-form-item label="工号：">
                        <el-input size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="用户名：">
                        <el-input size="small"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button size="mini" type="primary">查询</el-button>
                    </el-form-item>
                </el-form>
            </el-row>
            <el-table :data="tableData" size="small" border stripe>
                <el-table-column type="index" label="序号" align="center" :resizable="false" width="50"></el-table-column>
                <el-table-column prop="name" label="工号" :resizable="false" min-width="90"></el-table-column>
                <el-table-column prop="" label="姓名" :resizable="false" min-width="90"></el-table-column>
                <el-table-column prop="" label="厂" :resizable="false" min-width="90"></el-table-column>
                <el-table-column prop="" label="科室" :resizable="false" min-width="90"></el-table-column>
                <el-table-column prop="" label="备注" :resizable="false" min-width="90"></el-table-column>
                <el-table-column prop="" label="操作" fixed="right" min-width="60">
                    <template slot-scope="scope">
                        <el-button size="mini" type="primary" @click="setJobnumber(scope.row.name)">选择</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-row type="flex" justify="center">
                <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="pageSizeArr"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageTotal"></el-pagination>
            </el-row>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                dialogVisible: this.show,
                tableData: [{
                    id: '001',
                    name: '部门1'
                },{
                    id: '002',
                    name: '部门2'
                }],
                editId: '',
                pageSizeArr: [10, 20, 50],
                pageSize: 10,
                pageTotal: 20,
                currentPage: 1,
            }
        },
        props: {
            show: {
                type: Boolean,
                default: false
            }
        },
        watch: {
            show() {
                this.dialogVisible = this.show;
            }
        },
        methods: {
            handleClose() {
                this.dialogVisible = false;
            },
            handleSizeChange(val){
                // console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val){
                // console.log(`当前页: ${val}`);
            },
            // 选择选择通知的账号
            setJobnumber(account) {
                this.$emit('chooseAccount', account);   // 将选择的账户信息传递到父页面
                this.dialogVisible = false;
                this.$message({
                    message: '设置成功！',
                    type: 'success'
                });
            }
        }
    }
</script>